<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>问答知识库 | 专业税务咨询</title>
  <style>
      :root {
          --primary: #4361ee;
          --primary-light: #4895ef;
          --secondary: #3f37c9;
          --dark: #1b263b;
          --light: #f8f9fa;
          --gray: #6c757d;
          --glass: rgba(255, 255, 255, 0.15);
          --shadow: 0 8px 32px rgba(31, 38, 135, 0.1);
          --border-radius: 12px;
          --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
      }

      * {
          margin: 0;
          padding: 0;
          box-sizing: border-box;
      }

      body {
          font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
          background: linear-gradient(135deg, #f5f7fa 0%, #e4e8f0 100%);
          color: var(--dark);
          line-height: 1.6;
          min-height: 100vh;
          padding: 2rem 1rem;
      }

      .container {
          max-width: 1200px;
          margin: 0 auto;
      }

      header {
          text-align: center;
          margin-bottom: 3rem;
          opacity: 0;
          transform: translateY(20px);
          animation: fadeInUp 0.6s ease-out forwards;
      }

      h1 {
          font-size: 2.5rem;
          font-weight: 700;
          margin-bottom: 1rem;
          background: linear-gradient(90deg, var(--primary), var(--secondary));
          -webkit-background-clip: text;
          background-clip: text;
          color: transparent;
          letter-spacing: -0.5px;
      }

      .subtitle {
          font-size: 1.1rem;
          color: var(--gray);
          max-width: 600px;
          margin: 0 auto;
      }

      .search-container {
          max-width: 800px;
          margin: 0 auto 3rem;
          position: relative;
          opacity: 0;
          transform: translateY(20px);
          animation: fadeInUp 0.6s ease-out 0.2s forwards;
      }

      .search-box {
          display: flex;
          background: white;
          border-radius: var(--border-radius);
          box-shadow: var(--shadow);
          overflow: hidden;
          transition: var(--transition);
      }

      .search-box:focus-within {
          box-shadow: 0 8px 32px rgba(67, 97, 238, 0.2);
      }

      #searchInput {
          flex: 1;
          padding: 1.2rem 1.5rem;
          border: none;
          font-size: 1rem;
          outline: none;
          background: transparent;
      }

      #searchBtn {
          padding: 0 2rem;
          background: linear-gradient(135deg, var(--primary), var(--secondary));
          color: white;
          border: none;
          cursor: pointer;
          font-weight: 600;
          transition: var(--transition);
          display: flex;
          align-items: center;
          gap: 0.5rem;
      }

      #searchBtn:hover {
          opacity: 0.9;
      }

      .search-icon {
          width: 20px;
          height: 20px;
      }

      .results-container {
          display: grid;
          grid-template-columns: 1fr;
          gap: 1.5rem;
      }

      .result-card {
          background: rgba(255, 255, 255, 0.8);
          backdrop-filter: blur(10px);
          -webkit-backdrop-filter: blur(10px);
          border-radius: var(--border-radius);
          padding: 2rem;
          box-shadow: var(--shadow);
          border: 1px solid var(--glass);
          opacity: 0;
          transform: translateY(20px);
          transition: var(--transition);
      }

      .result-card.visible {
          opacity: 1;
          transform: translateY(0);
      }

      .question {
          font-size: 1.2rem;
          font-weight: 600;
          margin-bottom: 1rem;
          color: var(--dark);
          display: flex;
          align-items: flex-start;
          gap: 0.75rem;
      }

      .question:before {
          content: "Q";
          font-size: 0.9rem;
          font-weight: 700;
          color: white;
          background: var(--primary);
          width: 24px;
          height: 24px;
          border-radius: 50%;
          display: flex;
          align-items: center;
          justify-content: center;
          flex-shrink: 0;
          margin-top: 2px;
      }

      .answer {
          color: var(--gray);
          padding-left: 2.5rem;
          position: relative;
      }

      .answer:before {
          content: "A";
          font-size: 0.9rem;
          font-weight: 700;
          color: white;
          background: var(--secondary);
          width: 24px;
          height: 24px;
          border-radius: 50%;
          display: flex;
          align-items: center;
          justify-content: center;
          position: absolute;
          left: 0;
          top: 0;
      }

      .empty-state {
          text-align: center;
          padding: 3rem;
          color: var(--gray);
          opacity: 0;
          transform: translateY(20px);
          animation: fadeInUp 0.6s ease-out forwards;
      }

      .empty-icon {
          font-size: 3rem;
          margin-bottom: 1rem;
          opacity: 0.5;
      }

      footer {
          text-align: center;
          margin-top: 4rem;
          color: var(--gray);
          font-size: 0.9rem;
          opacity: 0;
          animation: fadeIn 0.6s ease-out 0.4s forwards;
      }

      @keyframes fadeInUp {
          from {
              opacity: 0;
              transform: translateY(20px);
          }
          to {
              opacity: 1;
              transform: translateY(0);
          }
      }

      @keyframes fadeIn {
          from {
              opacity: 0;
          }
          to {
              opacity: 1;
          }
      }

      @media (max-width: 768px) {
          h1 {
              font-size: 2rem;
          }

          .search-box {
              flex-direction: column;
          }

          #searchInput {
              padding: 1rem;
          }

          #searchBtn {
              padding: 1rem;
              justify-content: center;
          }

          .result-card {
              padding: 1.5rem;
          }

          .answer {
              padding-left: 2rem;
          }
      }

      @media (max-width: 500px) {
          body {
              padding: 1.5rem 1rem;
          }

          h1 {
              font-size: 1.8rem;
          }

          .subtitle {
              font-size: 1rem;
          }

          .result-card {
              padding: 1.25rem;
          }
      }
  </style>
</head>
<body>
<div class="container">
  <header>
    <h1>税务问答知识库</h1>
    <p class="subtitle">专业税务咨询与政策解读，为您提供权威的财税问题解决方案</p>
  </header>

  <div class="search-container">
    <div class="search-box">
      <input type="text" id="searchInput" placeholder="输入关键词搜索税务问题...">
      <button id="searchBtn">
        <svg class="search-icon" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
          <path d="M11 19C15.4183 19 19 15.4183 19 11C19 6.58172 15.4183 3 11 3C6.58172 3 3 6.58172 3 11C3 15.4183 6.58172 19 11 19Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
          <path d="M21 21L16.65 16.65" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
        </svg>
        搜索
      </button>
    </div>
  </div>

  <div class="results-container" id="resultsContainer">
    <!-- 结果将通过JS动态生成 -->
  </div>
</div>

<footer>
  <p>网页由问小白生成，仅供参考</p>
  <p>最后更新时间为2025-04-23 ，星期三</p>
  <p>wenxiaobai.com</p>
</footer>

<script>
  let qaData = []
  // 替换qaData的初始化部分
  fetch('qa.json')
    .then(response => response.json())
    .then(data => {
      qaData = data;
      displayResults(qaData);
    })
    .catch(error => console.error('加载数据失败:', error));
  // 示例数据


  // DOM元素
  const searchInput = document.getElementById('searchInput');
  const searchBtn = document.getElementById('searchBtn');
  const resultsContainer = document.getElementById('resultsContainer');


  // 搜索函数
  function search() {
    const keyword = searchInput.value.trim().toLowerCase();
    const results = keyword ?
      qaData.filter(item =>
        item.question.toLowerCase().includes(keyword) ||
        item.answer.toLowerCase().includes(keyword)
      ) : qaData;

    displayResults(results);
  }
  document.getElementById('searchInput').addEventListener('input', function(e) {
    search()
  })
  // 显示结果
  function displayResults(results) {
    resultsContainer.innerHTML = '';

    if (results.length === 0) {
      resultsContainer.innerHTML = `
                    <div class="empty-state">
                        <div class="empty-icon">🔍</div>
                        <h3>未找到匹配结果</h3>
                        <p>尝试使用不同的关键词进行搜索</p>
                    </div>
                `;
      return;
    }

    results.forEach((item, index) => {
      const resultCard = document.createElement('div');
      resultCard.className = 'result-card';
      resultCard.innerHTML = `
                    <div class="question">${highlightText(item.question, searchInput.value.trim())}</div>
                    <div class="answer">${highlightText(item.answer, searchInput.value.trim())}</div>
                `;
      resultsContainer.appendChild(resultCard);

      // 添加动画延迟
      setTimeout(() => {
        resultCard.classList.add('visible');
      }, 100 * index);
    });
  }

  // 高亮文本
  function highlightText(text, keyword) {
    if (!keyword) return text;
    const regex = new RegExp(keyword, 'gi');
    return text.replace(regex, match => `<span style="background-color: rgba(67, 97, 238, 0.2); padding: 0 2px; border-radius: 2px;">${match}</span>`);
  }

  // 事件监听
  searchBtn.addEventListener('click', search);
  searchInput.addEventListener('keypress', (e) => {
    if (e.key === 'Enter') search();
  });
  searchInput.addEventListener('input', () => {
    if (searchInput.value.trim() === '') search();
  });
</script>
</body>
</html>
